
Namespace myBookmarks.Core

    Public Class User

        Public Sub New()
            _usercontacts = New List(Of UserContact)
        End Sub
        Private _UserName As String
        Public Property UserName() As String
            Get
                Return _UserName
            End Get

            Set(ByVal value As String)
                _UserName = value
            End Set
        End Property



        Private _UserId As Guid
        Public Property UserId() As Guid
            Get
                Return _UserId
            End Get

            Set(ByVal value As Guid)
                _UserId = value
            End Set
        End Property



        Private _FirstName As String
        Public Property FirstName() As String
            Get
                Return _FirstName
            End Get

            Set(ByVal value As String)
                _FirstName = value
            End Set
        End Property



        Private _LastName As String
        Public Property LastName() As String
            Get
                Return _LastName
            End Get

            Set(ByVal value As String)
                _LastName = value
            End Set
        End Property



        Private _Email As String
        Public Property Email() As String
            Get
                Return _Email
            End Get

            Set(ByVal value As String)
                _Email = value
            End Set
        End Property

        Private _CreatedDate As DateTime
        Public Property CreatedDate() As DateTime
            Get
                Return _CreatedDate
            End Get

            Set(ByVal value As DateTime)
                _CreatedDate = value
            End Set
        End Property

        Private _LastVisited As DateTime
        Public Property LastVisited() As DateTime
            Get
                Return _LastVisited
            End Get

            Set(ByVal value As DateTime)
                _LastVisited = value
            End Set
        End Property

        Private _PasswordHash As String
        Public Overridable Property PasswordHash() As String
            Get
                Return _PasswordHash
            End Get
            Set(ByVal value As String)
                _PasswordHash = value
            End Set
        End Property
        Private _PasswordSalt As String
        Public Overridable Property PasswordSalt() As String
            Get
                Return _PasswordSalt
            End Get
            Set(ByVal value As String)
                _PasswordSalt = value
            End Set
        End Property

        Private _ResetPasswordToken As Nullable(Of Guid)
        Public Property ResetPasswordToken() As Nullable(Of Guid)
            Get
                Return _ResetPasswordToken
            End Get
            Set(ByVal value As Nullable(Of Guid))
                _ResetPasswordToken = value
            End Set
        End Property


        Private _usercontacts As List(Of UserContact)
        Public Property UserContacts() As List(Of UserContact)
            Get
                Return _usercontacts
            End Get
            Set(ByVal value As List(Of UserContact))
                _usercontacts = value
            End Set
        End Property

        Public Sub AddUserContact(ByVal email As String)

            Dim listContacts = From uc In UserContacts _
                               Where uc.UserContact.ToLower = email _
                               Select uc
            If Not listContacts.Any Then
                UserContacts.Add(New UserContact With {.UserName = UserName, .UserContact = email})
            End If

        End Sub

        Public Overridable Function IsAdmin() As Boolean
            Dim userIsAdmin As Boolean = UserName = "admin"
            Return userIsAdmin
        End Function

        Public Overrides Function ToString() As String

            If String.IsNullOrEmpty(FirstName) Then
                Return UserName
            Else
                Return String.Format("{0} {1}", FirstName, LastName)
            End If
        End Function
    End Class
End Namespace
